package com.fang.controller;

import com.fang.entity.UsAdmin0;
import com.fang.service.UsAdmin0Service;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 后台用户表(UsAdmin0)表控制层
 *
 * @author makejava
 * @since 2022-11-11 16:44:54
 */
@RestController
@RequestMapping("usAdmin0")
public class UsAdmin0Controller {
    /**
     * 服务对象
     */
    @Resource
    private UsAdmin0Service usAdmin0Service;

    @GetMapping("select")
    public List<UsAdmin0> select(@RequestBody UsAdmin0 usAdmin0) {
        List<UsAdmin0> select = usAdmin0Service.select();
        return select;
    }



    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("{id}")
    public ResponseEntity<UsAdmin0> queryById(@PathVariable("id") Long id) {
        return ResponseEntity.ok(this.usAdmin0Service.queryById(id));
    }

    /**
     * 新增数据
     *
     * @param usAdmin0 实体
     * @return 新增结果
     */
    @PostMapping
    public ResponseEntity<UsAdmin0> add(UsAdmin0 usAdmin0) {
        return ResponseEntity.ok(this.usAdmin0Service.insert(usAdmin0));
    }

    /**
     * 编辑数据
     *
     * @param usAdmin0 实体
     * @return 编辑结果
     */
    @PutMapping
    public ResponseEntity<UsAdmin0> edit(UsAdmin0 usAdmin0) {
        return ResponseEntity.ok(this.usAdmin0Service.update(usAdmin0));
    }

    /**
     * 删除数据
     *
     * @param id 主键
     * @return 删除是否成功
     */
    @DeleteMapping
    public ResponseEntity<Boolean> deleteById(Long id) {
        return ResponseEntity.ok(this.usAdmin0Service.deleteById(id));
    }

}

